package com.dirtylily.myblog.controller;

import com.dirtylily.myblog.pojo.Tag;
import com.dirtylily.myblog.pojo.blog;
import com.dirtylily.myblog.service.BlogService;
import com.dirtylily.myblog.service.TagService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Controller
//对应博客归档
public class ArchivesController {
    @Autowired
    private TagService tagService;
    @Autowired
    BlogService blogService;
    @GetMapping("/archives")
    public String archives( Model model) {
        //通过map存储对应年份的blog
        Map<String, List<blog>> stringListMap = blogService.archiveBlog();
        model.addAttribute("archiveMap",stringListMap);
       System.out.println(stringListMap);
       //统计博客总数
        model.addAttribute("blogCount", blogService.countBlog());
        return "archives";
    }
}
